<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>添加日志</title>
    <script type="text/javascript" src="../../static/common/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="../../static/common/jquery/jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" href="../../static/common/layui/css/layui.css">
</head>
<body>
<div style="margin: 15px;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label layui-form-newlabel_ren">实习日志</label>
            <div style="    margin-left: 110px;">
                <textarea id="ta_ckeditor" class="ckeditor my-math" cols="20" rows="2" style="overflow:auto; height:800px"></textarea>
                <script >CKEDITOR.replace('ta_ckeditor');</script>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="edit">上传日志</button>
            <input type="button" class="layui-btn"  lay-submit="" lay-filter="return" value="返回">
        </div>
    </div>
</div>
<script src="../../static/common/layui/layui.js"></script>
<script>
    var userid = ${sessionScope.currentUser.getId()};
</script>
<script>
    var myDate = new Date();
    layui.use(['form','jquery','layer'],function() {
        var form = layui.form(),
            $ = layui.jquery;
        var da = new Date();

        var myDate=da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate() + " " + da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds();
        var employer;
//        axios.get("/internlog/find/"+userid)
//                .then(function (response) {
//                // console.log(response);
//                employer=response.data.data.employ;
//                // console.log(vm.internInfo);
//            })
//            .catch(function (response) {
//                console.log(response);
//            });
        form.on('submit(edit)', function (data) {
            data.field.composerid = ${sessionScope.currentUser.getId()};
            data.field.content= CKEDITOR.instances.ta_ckeditor.getData();
            data.field.date=myDate;
            console.log(myDate);
            console.log(data.field);
            $.ajax({
                url:'/internlog/addOne'
                ,type:'post'
                ,contentType : "application/json; charset=utf-8"
                ,data:JSON.stringify(data.field)
                ,dataType:'json'
                ,success:function (response) {
                    layer.msg(response.message,{time: 1500},function () {
                        location.reload();
                        location.href='/student/practiceDiary1';
                    });
                }
            });
            return false;
        });
        form.on('submit(return)',function () {
            location.reload();
            location.href='/student/practiceDiary1';
        });
    })
</script>
</body>
</html>
